﻿@model vITs.Site.Models.ActionModels.AddTripModel
@using vITs.Site.Models 
@using vITs.Site.Models.DataModels
@{
    this.ViewBag.Title = "Lägg till resa";
}
@using (this.Html.BeginForm())
{
    <fieldset>
        <legend>
            <h2>Lägg till resa</h2>
        </legend>
        <p>Uppdrag: @this.ViewBag.Assignment.AssignmentName</p>
        <input type="hidden" name="AssignmentId" id="AssignmentId" value="@this.ViewBag.Assignment.AssignmentId" />
        @this.Html.ValidationSummary(false)
        <br />
        @Html.LabelFor(m => m.StartLocation)
        <br />
        @Html.EditorFor(m => m.StartLocation)
        <br />
        @Html.LabelFor(m => m.StartDate)
        <br />
        @Html.EditorFor(m => m.StartDate)
        <br />
        @Html.LabelFor(m => m.EndLocation)
        <br />
        @Html.EditorFor(m => m.EndLocation)
        <br />
        @Html.LabelFor(m => m.EndDate)
        <br />
        @Html.EditorFor(m => m.EndDate)
        <br />
        @Html.LabelFor(m => m.TransportationMode)
        <br />
        @{ var selectList = (this.Model == null ? TransportationMode.Car.ToSelectList() : this.Model.TransportationMode.ToSelectList()); }
        @Html.DropDownListFor(m => m.TransportationMode, selectList, new { onchange = "javascript:toggleTransportationMode(this);" })
        <br />
        @Html.LabelFor(m => m.TransportationCost)
        <br />
        @Html.EditorFor(m => m.TransportationCost)
        <br />
        <!--
        <div id="accountsWrapper">
            <p>Konton: @this.Html.ValidationMessage("Accounts")</p>
            <div id="accountList"></div>
            <input type="button" value="Lägg till konto" onclick="javascript:tripPoster.addAccount()" />
        </div>
        <input type="button" value="Lägg till" onclick="javascript:tripPoster.submit()" />
        //-->
        <input type="submit" value="Spara" />
    </fieldset>
}

<script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>
<script src="../../Scripts/tripPoster.js" type="text/javascript"></script>
<link href="../../Content/themes/base/jquery.ui.all.css" media="all" rel="Stylesheet" type="text/css" />
<script type="text/javascript">
    $('#StartDate').datepicker();
    $('#EndDate').datepicker();

    function toggleTransportationMode(e) {
        var val = e.value;
        var lbl = $('label[for="TransportationCost"]');
        switch (val) {
            case "1":
                lbl.html("Antal körda mil");
                break;
            default:
                lbl.html("Biljettkostnad");
                break;
        }
    }
    toggleTransportationMode(document.getElementById("TransportationMode"));
    tripPoster.addAccount();
</script>